package edu.scut.course_management.po;

import edu.scut.course_management.dto.AddCourseDTO;

/**
 * 持久化对象：课程
 * @author thompson
 */
public class Course {
    private Integer courseTypeId;
    private Integer courseId;
    private Integer departmentId;
    private String title;
    private Integer classHours;
    private Double credits;

    

    public Integer getCourseTypeId() {
        return courseTypeId;
    }

    public void setCourseTypeId(Integer courseTypeId) {
        this.courseTypeId = courseTypeId;
    }

    public Integer getCourseId() {
        return courseId;
    }

    public void setCourseId(Integer courseId) {
        this.courseId = courseId;
    }

    public Integer getDepartmentId() {
        return departmentId;
    }

    public void setDepartmentId(Integer departmentId) {
        this.departmentId = departmentId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Integer getClassHours() {
        return classHours;
    }

    public void setClassHours(Integer classHours) {
        this.classHours = classHours;
    }

    public Double getCredits() {
        return credits;
    }

    public void setCredits(Double credits) {
        this.credits = credits;
    }

    @Override
    public String toString() {
        return "Course {" + 
               "classHours=" + classHours + 
               ", courseId=" + courseId + 
               ", courseTypeId=" + courseTypeId + 
               ", credits=" + credits + 
               ", departmentId=" + departmentId + 
               ", title=" + title + 
               "]";
    }

    //对除courseId之外的属性进行判断，是否一致
    @Override
    public boolean equals(Object obj){
        if(!(obj instanceof Course)){
            return false;
        }
        else{
            return courseTypeId.equals(((Course)obj).getCourseTypeId())&&
                   departmentId.equals(((Course)obj).getDepartmentId())&&
                   title.equals(((Course)obj).getTitle())&&
                   classHours.equals(((Course)obj).getClassHours())&&
                   credits.equals(((Course)obj).getCredits());
        }
    }

    public Course(AddCourseDTO addCourseDTO, Integer courseTypeId, Integer departmentId) {
        this.courseTypeId = courseTypeId;
        this.courseId = null;
        this.departmentId = departmentId;
        this.title = addCourseDTO.getTitle();
        this.classHours = addCourseDTO.getClassHours();
        this.credits = addCourseDTO.getCredits();
    }

    public Course(){

    }
    
}